Skip to content

feat: Clean up StateDB methods, bump revm#238

Open
0xForerunner wants to merge 3 commits intoalloy-rs:mainfrom
0xForerunner:state-db-methods
Open

feat: Clean up StateDB methods, bump revm#238
0xForerunner wants to merge 3 commits intoalloy-rs:mainfrom
0xForerunner:state-db-methods

Conversation

@0xForerunner
Copy link
Contributor

@0xForerunner 0xForerunner commented Dec 4, 2025

This PR removes unnecessary methods from StateDB in favour of using DatabaseCommitExt. See #234 and this pr for more details.

Additionally we've added a few more trait methods to abstract away from revm::State.

You can see why this is required by taking a look at this pr into reth.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@0xForerunner
Copy link
Contributor Author

Apologies for the delay @mattsse @klkvr, looks like I forgot about this for a while. Should be ready to go as everything has been merged in revm

@0xForerunner
Copy link
Contributor Author

@mattsse @klkvr Bumping

@klkvr
Copy link
Member

klkvr commented Feb 25, 2026

iiuc those changes are needed just to make BasicBlockBuilder work with this in reth? I'd be fine with it just using &mut State<DB>

@0xForerunner
Copy link
Contributor Author

@klkvr We need the extra trait methods for this PR into reth.

The ultimate reason is for block access lists. We have a BAL implementation which requires the use of a wrapper type around State. This isn't possible without these methods.

@0xForerunner
Copy link
Contributor Author

@klkvr just rebased on main. Should be good to go!

@klkvr
Copy link
Member

klkvr commented Feb 27, 2026

@0xForerunner it's still not obvious to me why we need those methods to be honest. does your BAL implementation require the block builder to hold your custom database?

@0xForerunner
Copy link
Contributor Author

@klkvr You can see the implementation of StateDB for our BalBuilderDb here

When we're executing the bal we need access to the bundle state, like here

And we need merge_transitions here

You can see our BalBuilderDb wraps the underlying DB

Lemme know if you need anything else to justify these changes!

@0xForerunner
Copy link
Contributor Author

@klkvr rebased. Should be ready again.

@0xForerunner
Copy link
Contributor Author

Hey @mattsse If you mind taking a look at this it would be swell! Maintaining this fork though alloy-rs/evm -> reth -> op-reth is a bit painful :p

/// we at any time revert state of bundle to the state before transition
/// is applied.
fn merge_transitions(&mut self, retention: BundleRetention);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not entirely clear to me why this abstraction is needed, what is your usecase? right now basic block executors are already agnostic of concrete db

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klkvr did you miss this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this abstraction because our access list block builder needs to be able to wrap revm::State

Copy link
Member

@klkvr klkvr Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yep sorry missed it, just to confirm — you need this so that your custom block builder can use BasicBlockBuilder::finish API directly instead of duplicating the logic?

i'm quite happy with the way current abstraction works in a sense that it allows any database to be used for a BlockExecutor. if we need an additional abstraction for State db specific methods i'd prefer it to not affect BlockExecutorFactory trait at all but instead only be used for the reth's block builder construction methods

i'd be open to moving StateDB trait entirely into reth for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what you're suggesting. We already have StateDB used in the BlockExecutor impls. What is your reasoning for not wanting this? The previous implementation relied directly on revm::State, which is strictly less flexible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep and current implementation works with any database which is very flexible which is why I'm a bit hesitant on making it stricter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants